/* 
 * CleanShutdown.java 12.02.2012
 *  
 *  
 * Candidate: Alessandra Otterbach
 * Prometric ID: Algisina1
 * Username: Algisina
 *  
 * Sun Certified Developer for Java 2 Platform, Standard Edition Programming 
 * Assignment (CX-310-252A)
 *  
 * This class is part of the Programming Assignment of the Sun Certified 
 * Developer for Java 2 Platform, Standard Edition certification program, must 
 * not be used out of this context and must be used exclusively by Sun 
 * Microsystems, Inc. 
 */
package suncertify.ps;

import java.io.IOException;

import suncertify.db.Data;

/**
 * This class provides functionality to do a clean shutdown of the application
 * whenever it is closed.
 * 
 * @author Alessandra Otterbach
 * @see Runtime#addShutdownHook(Thread)
 */
public class CleanShutdown extends Thread {
    private String dbPath = null;

    public CleanShutdown(String dbPath) {
	this.dbPath = dbPath;
    }

    public void run() {
	try {
	    Data database = Data.getInstance(dbPath);
	    database.setDatabaseLocked(true);
	} catch (IOException e) {
	}
    }
}
